package com.mdxx.xczd.ui.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import com.mdxx.xczd.R;
import com.mdxx.xczd.adapter.PhoneAdapter;
import com.mdxx.xczd.app.App;

public class PhoneActivity extends AppCompatActivity {

    private ListView listView;
    private PhoneAdapter phoneAdapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_phone);
        listView = (ListView)findViewById(R.id.login_list_user);
        listView.setOnItemClickListener(onItemClick);
        listView.setAdapter(phoneAdapter= new PhoneAdapter(this,App.barCodeBean.getIceNums()));
        listView.setSelection(0);
    }

    private AdapterView.OnItemClickListener onItemClick = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                                long arg3) {
            Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+ App.barCodeBean.getIceNums().get(arg2).getPhoneNum()));
            startActivity(intent);
        }
    };

}
